package com.sugon.column

import org.apache.spark.sql.{DataFrame, SparkSession}

/**
  * @Title: ChangeColum
  * @ProjectName sparkdemoscala
  * @Description: TODO
  * @author weiwei
  * @date 2020/12/27 16:51
  */
object ChangeColum {


  def main(args: Array[String]): Unit = {

    val spark: SparkSession = SparkSession.builder().appName("change columns")
      .master("local[*]")
      .enableHiveSupport()
      .getOrCreate()


    val df: DataFrame = spark.read.orc("/xxxx")

    val seq: Seq[String] = df.columns.map((f: String) => f.toLowerCase()).toSeq

    //TODO !!!!!!! :_*
    val newDF: DataFrame = df.toDF(seq: _*)

    newDF.write.format("orc").mode("append").saveAsTable("xxx.xxx")

    spark.close()

  }
}
